home *** CD-ROM | disk | FTP | other *** search
- /*
- * Author: Yogish Baliga
- * Company: Yahoo! Inc.
- * Date: 23rd August, 2006
- *
- * All bookmarks are stored in bookmarks.rdf file located in the profile directory. Inverse index of
- * tags to bookmark resource is also stored in bookmarks.rdf.
- *
- * NC:YBookmarksRoot is the container for all the bookmarks in the system.
- * NC:YBookmarksTagRoot is the container for all the tags in the system.
- *
- * Elements within NC:YBookmarksRoot are the resource references. Each reference point to the individual
- * bookmarks. Each bookmark resource has outgoing arcs.
- * NC:Name - nsIRDFLiteral
- * NC:URL - nsIRDFResource
- * NC:Description - nsIRDFLiteral
- * NC:LastCharset - nsIRDFLiteral
- * NC:tag - nsIRDFLiteral (multiple)
- *
- * Elements within NC:YBookmarksTagRoot are the resource refrences. Each refrence point to the container.
- * These container has 1 outgoing arc and references to the bookmark resources.
- *
- * Outgoing arc is http://www.mozilla.org/bookmark#tagvalue. The target of this relation is the
- * actual tag value (nsIRDFLiteral).
- *
- * ----------------------
- * --->| NC:YBookmarksTopRoot |
- * | ----------------------
- * |
- * | ------------------- contains ----------------------
- * |------| NC:YBookmarksRoot |----------------------->| bookmark resource | contains
- * | ------------------- | (Anonymous resource) |<---------------
- * | ---------------------- |
- * | |
- * | |
- * | ---------------------- contains ---------------------- contains ----------------------
- * ------| NC:YBookmarksTagRoot |------------->| Tag Sequence |------------->| Tag resource |
- * ---------------------- | (Anonymous resource) | | (Anonymous resource) |
- * ---------------------- ----------------------
- *
- *
- * NC:YBookmarksRoot has the following outgoing arcs:
- *
- * * http://www.w3.org/1999/02/22-rdf-syntax-ns#type => http://home.netscape.com/NC-rdf#Folder
- * * http://home.netscape.com/NC-rdf#LastUpdateDate => nsIRDFLiteral ( set to the string provided by the service provider.
- * This can be used for incremental updates
- * )
- *
- * Following are the Arcs out of bookmark resource
- *
- * * http://home.netscape.com/NC-rdf#URL - nsIRDFResource
- * * http://home.netscape.com/NC-rdf#Name - nsIRDFLiteral
- * * http://home.netscape.com/NC-rdf#Description - nsIRDFLiteral
- * * http://home.netscape.com/NC-rdf#LastCharset - nsIRDFLiteral
- * * http://home.netscape.com/NC-rdf#WebPanel - nsIRDFLiteral
- * * http://home.netscape.com/NC-rdf#BookmarkAddDate - nsIRDFDate
- * * http://home.netscape.com/NC-rdf#LastVisitDate - nsIRDFDate
- * * http://home.netscape.com/NC-rdf#LastModifiedDate - nsIRDFDate
- * * http://home.netscape.com/NC-rdf#VisitCount - nsIRDFInt
- *
- * * http://www.mozilla.org/bookmark#tag ( There are multiple arcs of this resource )
- *
- * Tag Sequence is having the following attribute
- * * http://www.mozilla.org/bookmark#tagvalue - nsIRDFLiteral
- * * http://home.netscape.com/NC-rdf#ChildCount - nsIRDFInt
- *
- */
-
- /*
- * All functionality is moved to singleton object. Here is how to obtain the ybookmarks service object.
- *
- * var bookmarksService = Components.classes["@mozilla.org/ybookmarks-service;1"].
- * getService( Components.interfaces.nsIYBookmarkService );
- *
- * See components/nsIYBookmarksService.idl for the methods exposed by nsIYBookmarksService interface.
- *
- * Q. How to add bookmark
- * A.
- * var tags = [ "Hello", "World" ];
- * bookmarksService.addBookmark( "http://www.yahoo.com", "Yahoo!", "charset string", false, "Some Description", tags.length, tags );
- *
- * Q. How to get all tags
- * A.
- * var allTags = bookmarksService.getTags(null, {} );
- *
- * Note: 2nd parameter is necessary here because of some XPCOM limitations.
- *
- * for ( var counter = 0; counter < allTags.length; ++counter) {
- * yDebug.print( "Tag => " + allTags[counter] );
- * }
- *
- * Q. How to get tags for a given URL?
- * A.
- * var tags = bookmarksService.getTags( "http://www.yahoo.com", {} );
- *
- * See the previous answer for how to loop through the tags.
- *
- * Q. How to get bookmarks for a given tag.
- * A.
- * var bookmarks = bookmarksService.getBookmarks( "tag", {} );
- *
- * bookmarks is an array of instance of nsIYBookmark.
- * Following are the members of the instance:
- * name => Title of bookmark
- * url => URL of bookmark
- * description => Description of bookmark
- * charset => Charset of the web page
- * tags => An instance of nsIArray. Each element of this array is nsISupportsString
- * This is because of the limitation of IDL in XPCOM.
-
- * In Javascript it can be accessed as
- *
- * for ( var counter = 0; counter < bookmarks.length; ++counter ) {
- * var book = bookmarks[counter];
- * yDebug.print ( "Title => " + book.name );
- * yDebug.print ( "URL => " + book.url );
- * yDebug.print ( "Description => " + book.description );
- * yDebug.print ( "Charset => " + book.charset );
- *
- * // Tags is somewhat trikcy.
- * var tags = book.tags.enumerate();
- * while ( tags.hasMoreElements() ) {
- * var tag = tags.getNext().QueryInterface( Components.interfaces.nsISupportsString).data;
- yDebug.print ( "Tag => " + tag );
- * }
- * }
- *
- * Q. How to add custom keys to bookmark?
- * A. Use get and set methods as in nsIYBookmarkService.idl file.
- * Following methods are provided:
- *
- * * setBookmarkKeyAsString ( url, key, value )
- * * setBookmarkKeyAsInt ( url, key, value )
- * * setBookmarkKeyAsDate ( url, key, value )
- *
- * Bulk set methods: (number of elements in keys and values must be equal to or greater than totalkeys.
- * Only totalkeys key-value pair are added to the bookmark. Rest are ignored.
- * nth element in keys is set to nth element in values.
- )
- *
- * * setBookmarkKeysAsString ( url, totalkeys, keys, values )
- * * setBookmarkKeysAsInt ( url, totalkeys, keys, values )
- * * setBookmarkKeysAsDate ( url, totalkeys, keys, values )
- *
- * Following are the get methods: These methods return an array. Each element in the output array corresponds to the
- * value of key in the rdf. The element in the output array will have null if
- * correponding key is not in the rdf. Date and Int values are set to 0 if key are not
- * found in the rdf.
- *
- * * getBookmarkStringValues( url, totalkeys, keys, totalvalues )
- * * getBookmarkIntValues( url, totalkeys, keys, totalvalues )
- * * getBookmarkDateValues( url, totalkeys, keys, totalvalues )
- *
- * Example:
- *
- * bookmarksService.setBookmarkKeyAsString( "http://www.yahoo.com", "hash", "asdasdlaksdoqwieqwe" );
- * bookmarksService.setBookmarkKeyAsInt( "http://www.yahoo.com", "id", 10 );
- * bookmarksService.setBookmarkKeyAsDate( "http://www.yahoo.com", "dt", (new Date()).getTime() );
- *
- * bookmarksService.setBookmarkKeysAsString( "http://www.yahoo.com", 1, [ "hash" ], [ "lkjaoiwqeojqwoiejqowe" ] );
- * bookmarksService.setBookmarkKeysAsInt( "http://www.yahoo.com", 1, [ "id" ], [ 11 ] );
- * bookmarksService.setBookmarkKeysAsDate( "http://www.yahoo.com", 1, [ "dt" ], [ (new Date()).getTime() ] );
- *
- * Example to fetch the keys: (out.value is set to number of elements in the output array. The last parameter is required,
- * even though not used)
- *
- * var out = {};
- * var hashes = bookmarksService.getBookmarkStringValues( "http://www.yahoo.com", 1, ["hash" ], out );
- * var ids = bookmarksService.getBookmarkIntValues( "http://www.yahoo.com", 1, ["id" ], out );
- * var dts = bookmarksService.getBookmarkIntValues( "http://www.yahoo.com", 1, ["dt" ], out );
- *
- *
- * Q. How to set and get the last update time for the incremental updates from the service provider?
- * A. Use setLastUpdateTime and getLastUpdateTime methods.
- *
- * Example:
- * bookmarksService.setLastUpdateTime( "time string from service provider" );
- * var lastUpdateTime = bookmarksService.getLastUpdateTime();
- */
-
-